package com.stox.charting.ui.swing.widget;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import com.stox.charting.ui.swing.view.ChartingInternalFrameView;
import com.stox.core.ui.swing.wrapper.JButton;
import com.stox.core.ui.swing.wrapper.JToolBar;
import com.stox.ioc.Container;
import com.stox.resources.i18n.MessageSource;

public class ChartingToolBar extends JToolBar {
	private static final long serialVersionUID = 6539360796505500963L;

	private ChartSpanComboBox chartSpanComboBox;
	private BarSpanComboBox barSpanComboBox;
	private BarTypeComboBox barTypeComboBox;
	private JButton zoomInButton = new JButton(null,MessageSource.getMessage("ZoomIn"), "zoom_in.png", KeyEvent.VK_RIGHT);
	private JButton zoomOutButton = new JButton(null,MessageSource.getMessage("ZoomOut"), "zoom_out.png", KeyEvent.VK_LEFT);
	
	public ChartingToolBar() {
		chartSpanComboBox = Container.get(ChartSpanComboBox.class);
		barSpanComboBox = Container.get(BarSpanComboBox.class);
		barTypeComboBox = Container.get(BarTypeComboBox.class);
		add(chartSpanComboBox);
		add(barSpanComboBox);
		add(barTypeComboBox);
		add(zoomInButton);
		add(zoomOutButton);
		zoomInButton.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent e) {
				ChartingInternalFrameView view = ChartingInternalFrameView.getLastSelectedView();
				if(view != null){
					view.getZoom().in();
				}
			}
		});
		
		zoomOutButton.addActionListener(new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent e) {
				ChartingInternalFrameView view = ChartingInternalFrameView.getLastSelectedView();
				if(view != null){
					view.getZoom().out();
				}
			}
		});
		
		
	}
	
}
